gtk/window: Bring back L-shaped resize corners
authorCarlos Garnacho <carlosg@gnome.org>
Sat, 12 Dec 2020 00:32:16 +0000 (01:32 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 12 Dec 2020 00:42:42 +0000 (01:42 +0100)
These ended up square in the various refactors. Make them again L-shaped
by extending these along the edge being checked. This means we have to
check for corner positions in all edges, though.

gtk/gtkwindow.c

index c516bcdfc1b46fbea470b48fd1c39da00796593b..d3402c3a842987e5ff98e8e669df3360c272061a 100644 (file)
@@ -1309,10 +1309,10 @@ get_edge_for_coordinates (GtkWindow *window,
 
   if (x < left && x >= left - handle_size.left)
     {
-      if (y < top && y >= top - handle_size.top)
+      if (y < top + handle_size.top && y >= top - handle_size.top)
         return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_WEST);
 
-      if (y > top + border_rect->size.height &&
+      if (y > top + border_rect->size.height - handle_size.bottom &&
           y <= top + border_rect->size.height + handle_size.bottom)
         return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_WEST);
 
@@ -1321,24 +1321,36 @@ get_edge_for_coordinates (GtkWindow *window,
   else if (x > left + border_rect->size.width &&
            x <= left + border_rect->size.width + handle_size.right)
     {
-      if (y < top && y >= top - handle_size.top)
+      if (y < top + handle_size.top && y >= top - handle_size.top)
         return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_EAST);
 
-      if (y > top + border_rect->size.height &&
+      if (y > top + border_rect->size.height - handle_size.bottom &&
           y <= top + border_rect->size.height + handle_size.bottom)
         return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_EAST);
 
       return edge_or_minus_one (GDK_SURFACE_EDGE_EAST);
     }
-
-  if (y < top && y >= top - handle_size.top)
+  else if (y < top && y >= top - handle_size.top)
     {
-      /* NORTH_EAST is handled elsewhere */
+      if (x < left + handle_size.left && x >= left - handle_size.left)
+        return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_WEST);
+
+      if (x > left + border_rect->size.width - handle_size.right &&
+          x <= left + border_rect->size.width + handle_size.right)
+        return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_EAST);
+
       return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH);
     }
   else if (y > top + border_rect->size.height &&
            y <= top + border_rect->size.height + handle_size.bottom)
     {
+      if (x < left + handle_size.left && x >= left - handle_size.left)
+        return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_WEST);
+
+      if (x > left + border_rect->size.width - handle_size.right &&
+          x <= left + border_rect->size.width + handle_size.right)
+        return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_EAST);
+
       return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH);
     }